<template>
  <div class="topslist">
    <div v-for="(item, index) in $store.state.list" :key="index" class="zhan">
      <div class="he">
        <div class="tu"><img :src="item.img" alt="" /></div>
        <div class="zi">
          <div class="fzi">{{ item.desc }}</div>
          <h5>{{ item.name }} <span class="yiu" @click="add(item)">+</span></h5>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {},
  methods: {
    add(item) {
      this.$store.commit("add", item);
    },
  },
};
</script>

<style lang='scss' scoped>
.topslist {
  width: 100%;
  height: 100%;
  display: inline-flex;
  flex-wrap: wrap;
}
.zhan {
  width: 50%;
  height: 300px;

  .he {
    width: 100%;
    height: 100%;
    text-align: center;
    .tu {
      width: 80%;
      height: 60%;
      margin: 0 auto;
      img {
        width: 90%;
        height: auto;
      }
    }
    .zi {
      width: 80%;
      margin: 0 auto;
      font-size: 12px;
      .fzi {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      h5 {
        font-size: 16px;
        color: red;
        text-align: left;
        .yiu {
          display: inline-block;
          width: 20px;
          height: 20px;
          background-color: red;
          color: white;
          text-align: center;
          line-height: 20px;
          border-radius: 50%;
          // float: right;
        }
      }
    }
  }
}
</style>
